<%@ page contentType="text/html; charset=utf-8" language="java" import="java.util.*" pageEncoding="utf-8" errorPage="" %>
<%@ page import="club325.webchat.servlet.log.SessionAttributeManager" %>
<%@ page import="club325.webchat.servlet.log.UserAttribute" %>
<%@ page session="false" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/main.dwt.jsp" codeOutsideHTMLIsLocked="false" -->
<head>
<!-- InstanceBeginEditable name="doctitle" -->
<title>聊天连接</title>
<!-- InstanceEndEditable -->

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="Expires" content="0" />
<meta http-equiv="Keywords" content="WebChat,Chat" />
<meta http-equiv="Description" content="Chatting on Web" />
<!-- InstanceBeginEditable name="head" -->
<link href="/WebChat/style/chat_random.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/WebChat/lib/util.js"></script>
<script type="text/javascript">
<!--
	var disable = true;
	function resetLink(){
		disable = !disable;
		setTimeout('disable = !disable;document.getElementById("tip").innerHTML = "提示 : 点击按钮开始一个链接...";', 15000);
	}
//-->
</script>
<!-- InstanceEndEditable -->

<link href="/WebChat/style/global.css" rel="stylesheet" type="text/css" />
<link href="/WebChat/style/template.css" rel="stylesheet" type="text/css" />
</head>

<body>
<div id="top">
  <div id="top_main">
    <ul>
      <li><a href="#">设为首页</a>|</li>
      <li><a href="#">会员注册</a>|</li>
      <li><a href="#">用户登录</a>|</li>
      <li><a href="#">联系我们</a></li>
    </ul>
  </div>
</div>

<div id="main">
  <div id="head">
    <div id="head_main"><img src="/WebChat/images/logo.png" width="200" height="70" alt="logo" />
    <%
    	HttpSession session = request.getSession(false);
    	UserAttribute userAttribute = null;
    	String username = null;
    	String userrole = null;
    	boolean isUser = false;
    	boolean isAdmin = false;
    	if (session != null) {
    		userAttribute = (UserAttribute)session.getAttribute(SessionAttributeManager.SESSION_USERATTRIBUTE);
    		if (userAttribute != null) {
    			username = userAttribute.getUserName();
    			userrole = userAttribute.getUserRole();
    		}
    	}
    	if (username != null && userrole != null) {
    		if (userrole.equals(UserAttribute.USERROLE_ADMIN)) {
    			isUser = true;
    			isAdmin = true;
    		} else if (userrole.equals(UserAttribute.USERROLE_USER)) {
    			isUser = true;
    			isAdmin = false;
    		} else {
    			isUser = false;
    			isAdmin = false;
    		}
    %>
      <div id="head_main_info">
        <h1 class="<%= userrole %>"><%= username %></h1>
        <ul>
        <%
        	if (isUser) {
        %>
          <li><a href="/WebChat/pages/user_frame.jsp">个人中心</a>|</li>
        <%
        	}
        %>
          <li><a href="/WebChat/servlet/LogoutServlet">退出</a></li>
        </ul>
      </div>
    <%
    	}
    %>
    </div>
    <div id="head_nav">
      <ul>
        <li><a href="/WebChat/index.jsp">首 页</a></li>
        <li><a href="/WebChat/pages/chat_random.jsp">随机聊天</a></li>
        <li><a href="/WebChat/pages/chat_room.jsp">聊天室</a></li>
        <li><a href="/WebChat/servlet/HallChatServlet">聊天大厅</a></li>
        <%
        	if (isAdmin) {
      	%>
        <li><a href="/WebChat/pages/admin_frame.jsp">管理中心</a></li>
        <%
        	}
      	%>
      </ul>
      <%
        	if (isUser) {
      %>
      <p><a href="/WebChat/pages/user_frame.jsp"><img src="/WebChat/images/arrow_next.png" width="18" height="16" alt="arrow_next" />进入会员中心</a></p>
      <%
        	}
      %>
    </div>
  </div>
  <!-- InstanceBeginEditable name="EditRegion_body" -->
  <div id="body">
    <div id="body_middle">
      <a href="javascript:openBareWindow('_blank', '/WebChat/servlet/RandomChatServlet', 650, 500);resetLink()" onclick="document.getElementById('tip').innerHTML = '提示 : 正在链接, 请等待15秒...';return disable">开始连接...</a>
      <h1>&gt;&gt;当点击按钮后，我们会在15秒内随机选取另外一个同样点击了该按钮的用户和您进行搭配一对一的聊天...&lt;&lt;</h1>
      <h2 id="tip">提示 : 点击按钮开始一个链接...</h2>
    </div>
  </div>
  <!-- InstanceEndEditable -->
</div>

<div id="bottom">
  <p>Copyright © 2009 - 2010 CLUB325.  All Rights Reserved<br/>
  CLUB325  版权所有</p>
</div>
</body>
<!-- InstanceEnd --></html>
